<?php

$html = curlGet('http://www.pc6.com/softview/SoftView_250839.html');
$html = iconv('gb2312','UTF-8',$html);

$preg = '#<div id="softTit"><h1 itemprop="name">(.*)</h1>&nbsp;<span itemprop="version">.*</span></div>.*</div>.*<div id="param-box">.*<div id="param-content">.*<ul class="param-ul bluea">.*<li>软件大小：<span itemprop="fileSize">(.*)</span></li>.*<li>更新日期：<span class="pub-time" itemprop="dateModified">.*</span></li>.*<li>软件语言：<span itemprop="inLanguage">(.*)</span></li>.*<li>软件类别：<span>.*</span></li>.*<li>软件授权：<span itemprop="license">(.*)</span></li>.*<li class="gw">软件官网：<span itemprop="author"><a href="http://ppt.101.com/" target="_blank" rel="nofollow">.*</a></span></li>.*<li class="fullsize".*itemprop="operatingSystem">适用平台：<span>WinAll</span></li>.*<li></li>.*</ul>.*#isU';
preg_match_all($preg,$html,$res);
//print_r($res);die;
$name = $res[1];
$lunge = $res[3];
$info = $res[4];
$data = $res[2];
$dbh = new PDO('mysql:host=localhost;dbname=month', 'root', 'root');
$sql = "insert into datas(id,name,lunge,info,data) VALUES (NULL  $name,$lunge,$info,$data)";

$pdo = PDO::exec($sql);

function curlGet($url)
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_FAILONERROR, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    return curl_exec($curl);
}